package com.cfilmcloud.learn.demo;

import com.cfilmcloud.learn.demo.use.Person;

import java.util.Optional;

/**
 *  Description: 空<br>
 * 1、…<br>
 * 2、…<br>
 * Implement: <br>
 * 1、…<br>
 * 2、…<br>
 * 
 * @author mengxy[孟祥元][mengxiangyuan@cfilmcloud.com]
 * Created by edz on 2017/7/19.
 */
public class DemoNull {


    public static void main(String[] args) {
        {
            Person person = new Person();
            System.out.println(Optional.ofNullable(person)
                    .map(Person::getCountry)
                    .map(Person.Country::getProvinec)
                    .map(Person.Province::getCity)
                    .map(Person.City::getName)
                    .orElse("unkonwn"));
            if(null != person){
                if( null != person.getCountry()){

                }
            }
        }

        {
            Person person = null;
            System.out.println(Optional.ofNullable(person)
                    .map(Person::getCountry)
                    .map(Person.Country::getProvinec)
                    .map(Person.Province::getCity)
                    .map(Person.City::getName)
                    .orElse("unkonwn"));
        }
    }
}
